﻿/*
 *   TypeOfValue.cs
 *   Copyright (c) 2011 - BitFox Software and Ricardo Federico Villafañes
 *   Contact: federvillaf@hotmail.com
 *   
 *   Licensing: This product is covered by Microsoft Reciprocal License (MS-RL)
 *              see https://bitfoxeval.codeplex.com/license
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WFormSample
{
    /// <summary>
    /// Helper class that handles onscreen tips
    /// </summary>
    class Tips
    {
        /// <summary>
        /// The browser where tips are displayed
        /// </summary>
        WebBrowser browser;

        /// <summary>
        /// The index of tip that is currently in screen
        /// </summary>
        public int Actual { get; private set; }

        /// <summary>
        /// The total count of tips handled
        /// </summary>
        public int Total { get { return tips.Length; } }

        /// <summary>
        /// Helper method that show a tip.
        /// </summary>
        /// <param name="text"></param>
        void SetHtml(string text)
        {
            browser.DocumentText = "<html><font face='arial' size='2'>" + text + "</font></html>";
            browser.Update();
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="browser">The browser where to show the tip</param>
        public Tips(WebBrowser browser)
        {
            this.browser = browser;
            SetHtml(tips[1]);
        }

        /// <summary>
        /// Move to next tip and display it
        /// </summary>
        public void NextTip()
        {
            if (++Actual == Total) Actual = 0;
            SetHtml(tips[Actual]);
        }

        /// <summary>
        /// Move to previous tip and display it
        /// </summary>
        public void PreviousTip()
        {
            if (--Actual < 0) Actual = Total - 1;
            SetHtml(tips[Actual]);

        }

        /// <summary>
        /// The tips to show. HTML tags can be embedded
        /// </summary>
        string[] tips = new string[] 
        {
            "<b>General:</b><p>Fill the <b>Expression</b> box with a valid expression and push <b>Calculate</b> button to see results.</p>" +
            "<p>Samples of valid expressions are:<br><br>" +
            "&nbsp;&nbsp;&nbsp;&nbsp;(12 + 3) * 2<br>" +
            "&nbsp;&nbsp;&nbsp;&nbsp;'hello ' + 'gizmo'<br>" +
            "&nbsp;&nbsp;&nbsp;&nbsp;'Today is ' + DTOC(DATE())<br>" +
            "&nbsp;&nbsp;&nbsp;&nbsp;IIF(value<15, 'Too low!!', 'Normal')<br>" +
            "</p>",

            "<b>Numeric Expressions:</b><p>The evaluator handle integer and decimal calculations, without loss of precision. The promotion from integer to decimal is automatic or, if you want to force the use of decimals, use in your expression a constant with decimal part.</p>" +
            "<p>Too, there are available a lot of builtin functions to perform conversions (like <b>VAL</b> and <b>STR</b>), Trigonometric (Like <b>SIN</b> and <b>COS</b>) or Numeric (Like <b>ROUND</b>).</p>"

        };
    }
}
